package ru.aslanov.schedule.server;

import java.util.logging.Logger;

/**
 * @author Sergey Aslanov
 *         Created: Oct 14, 2010 12:29:32 PM
 */
public class InputLangUtil {
    private static final Logger log = Logger.getLogger(InputLangUtil.class.getName());

    private static final ThreadLocal<String> THREAD_LOCAL_INPUT_LANG = new ThreadLocal<String>();
    private static final ThreadLocal<String> THREAD_LOCAL_DEFAULT_INPUT_LANG = new ThreadLocal<String>();

    public static String getThreadLocalInputLang() {
        return THREAD_LOCAL_INPUT_LANG.get();
    }

    public static void setThreadLocalInputLang(String lang, String defaultLang) {
        log.fine("Setting thread local lang=" + lang + " defaultLang=" + defaultLang);    
        THREAD_LOCAL_INPUT_LANG.set(lang);
        THREAD_LOCAL_DEFAULT_INPUT_LANG.set(defaultLang);
    }

    public static void clearThreadLocalInputLang() {
        THREAD_LOCAL_INPUT_LANG.remove();
        THREAD_LOCAL_DEFAULT_INPUT_LANG.remove();
    }

    public static String getThreadLocalDefaultInputLang() {
        return THREAD_LOCAL_DEFAULT_INPUT_LANG.get();
    }

}
